package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceSupplies;
import com.ruoyi.service.service.IServiceSuppliesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 耗材表Controller
 * 
 * @author ZDL
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/service/supplies")
public class ServiceSuppliesController extends BaseController
{
    @Autowired
    private IServiceSuppliesService serviceSuppliesService;

    /**
     * 查询耗材表列表
     */
    @PreAuthorize("@ss.hasPermi('service:supplies:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceSupplies serviceSupplies)
    {
        startPage();
        List<ServiceSupplies> list = serviceSuppliesService.selectServiceSuppliesList(serviceSupplies);
        return getDataTable(list);
    }

    /**
     * 导出耗材表列表
     */
    @PreAuthorize("@ss.hasPermi('service:supplies:export')")
    @Log(title = "耗材表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceSupplies serviceSupplies)
    {
        List<ServiceSupplies> list = serviceSuppliesService.selectServiceSuppliesList(serviceSupplies);
        ExcelUtil<ServiceSupplies> util = new ExcelUtil<ServiceSupplies>(ServiceSupplies.class);
        util.exportExcel(response, list, "耗材表数据");
    }

    /**
     * 获取耗材表详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:supplies:query')")
    @GetMapping(value = "/{suppliesId}")
    public AjaxResult getInfo(@PathVariable("suppliesId") Long suppliesId)
    {
        return success(serviceSuppliesService.selectServiceSuppliesBySuppliesId(suppliesId));
    }

    /**
     * 新增耗材表
     */
    @PreAuthorize("@ss.hasPermi('service:supplies:add')")
    @Log(title = "耗材表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceSupplies serviceSupplies)
    {
        return toAjax(serviceSuppliesService.insertServiceSupplies(serviceSupplies));
    }

    /**
     * 修改耗材表
     */
    @PreAuthorize("@ss.hasPermi('service:supplies:edit')")
    @Log(title = "耗材表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceSupplies serviceSupplies)
    {
        return toAjax(serviceSuppliesService.updateServiceSupplies(serviceSupplies));
    }

    /**
     * 删除耗材表
     */
    @PreAuthorize("@ss.hasPermi('service:supplies:remove')")
    @Log(title = "耗材表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{suppliesIds}")
    public AjaxResult remove(@PathVariable Long[] suppliesIds)
    {
        return toAjax(serviceSuppliesService.deleteServiceSuppliesBySuppliesIds(suppliesIds));
    }
}
